function rotate(obj,varargin)
%ROTATE(U,THETA) rotates all atoms along direction U by THETA degrees


u = varargin{1};
theta = varargin{2}*pi/180;

u=u./norm(u);
cosa = cos(theta);
sina = sin(theta);
vera = 1 - cosa;
x = u(1);
y = u(2);
z = u(3);
rot3D = [cosa+x^2*vera x*y*vera-z*sina x*z*vera+y*sina; ...
          x*y*vera+z*sina cosa+y^2*vera y*z*vera-x*sina; ...
          x*z*vera-y*sina y*z*vera+x*sina cosa+z^2*vera]';


indexes = obj.Atoms.keys;      
natom = numel(indexes);
      
for k=1:natom
    Atom = obj.get_atom(indexes{k});
    pos = Atom.Position';
    Atom.Position = (rot3D*pos)';
    obj.set_atom(indexes{k},Atom);
end


end